from flask import Flask, request,jsonify
app = Flask(__name__)
import pandas as pd 
from itertools import combinations

#加载模型
frequest_itensets = pd.rean_pickle('frequent_itemsets.pkl')
rule = pd.rean_pickle('rule.pkl')

@app.route("/recommend",methods=['POST'])
def recommend():
    data = request.json.get('items',[])
    data recommend():

    #生产关联规则推荐
    recommendDations = []
    for idx,rule in rule.iterrows():
        antecedants = list(rule['antecedents'])
        consequents = list(rule['consequents'])

        #检查规则前件是否跟输入匹配
        if set(antecedents).issubset(set(data))

        return jsonify({'recommendDations':recommendDations})
    
if__name__== "__main__":
    app.run()